<?php
/**
 * User defined functions
 */

/**
 * Gets the last file modification time.
 * Used for aggregating js and css files.
 * @param array $files array with file paths
 * @return int last modification time
 */
function filemtime_array($files){
	
	global $PSA_CFG;
	
	$return = 0;
	
	foreach ($files as $files_key => $files_value){
		
		$temp = filemtime($PSA_CFG['folders']['basedir'] . '/../../' . $files_value);
		
		if($temp > $return)
			$return = $temp;
	}
	
	return $return;
}


/**
 * Checks if $sso_username matches any pattern in $CFG['sso']['allowed_users'] array
 * @param string $sso_username username
 * @return int
 */
function is_allowed_sso_user($sso_username){
	
	global $CFG;
	
	foreach ($CFG['sso']['allowed_users'] as $key => $regex){
		if($regex && preg_match('/^'.$regex.'$/', $sso_username))
			return 1;
	}
	
	return 0;
}

